<template>
  <div class="singleList">
      <div>
          <el-input v-model="input1" placeholder="编码" style="width: 200px;"></el-input>
          <el-input v-model="input2" placeholder="标题" style="width: 200px;"></el-input>
          <!-- 日期 -->
          <el-date-picker v-model="value1" type="date" placeholder="发布时间起">
          </el-date-picker>
          <el-date-picker v-model="value2" type="date" placeholder="发布时间止">
          </el-date-picker>
          <el-date-picker v-model="value3" type="date" placeholder="修改时间起">
          </el-date-picker>
          <el-date-picker v-model="value4" type="date" placeholder="修改时间止">
          </el-date-picker>
          <!-- 日期 -->
          <el-button type="primary" icon="el-icon-search">搜索</el-button>
          <el-button type="success" style="width: 80px;">+添加</el-button>



          <el-table :data="tableData" style="width: 100%" ailgn="center">
              <el-table-column prop="key" label="编号">
              </el-table-column>
              <el-table-column prop="title" label="标题">
              </el-table-column>
              <el-table-column label="操作">
                  <template slot-scope="scope">
                      <div>
                          <!-- {{ scope.row }} -->
                          <span @click="edit" style="color: blue;">编辑</span>
                          <span @click="del(scope.row)" style="color: red;">删除</span>
                      </div>
                  </template>
              </el-table-column>
          </el-table>
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
              :page-sizes="[1, 2, 3]" :page-size="parmas.pageSize" layout="total, sizes, prev, pager, next, jumper"
              :total="total">
          </el-pagination>
      </div>
  </div>
</template>


<script>
import { singleList } from '@/api/danye.js';
export default {
    data() {
        return {
            parmas: { page: 3, pageSize: 5 },
            currentPage: 1,
            total: 1,
            tableData: [{
                date: '2016-05-02',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1518 弄'
            }, {
                date: '2016-05-04',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1517 弄'
            }, {
                date: '2016-05-01',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1519 弄'
            }, {
                date: '2016-05-03',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1516 弄'
            }],
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > Date.now();
                },
                shortcuts: [{
                    text: '今天',
                    onClick(picker) {
                        picker.$emit('pick', new Date());
                    }
                }, {
                    text: '昨天',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24);
                        picker.$emit('pick', date);
                    }
                }, {
                    text: '一周前',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', date);
                    }
                }],
            },
            input1: '',
            input2: '',
            value1: '',
            value2: '',
            value3: '',
            value4: '',

        }
    },
    mounted() {
        this.getList()
    },
    methods: {
        async getList() {
            singleList(this.parmas)
            console.log(this.tableData)
            let { data: res } = await singleList(this.parmas)
            this.total = res.totalRow
            console.log(res);
            this.tableData = res.result
            this.singleList = this.tableData
        }, del(row) {
            console.log(row)
        },
        edit(row) {
            console.log(row);
        },
        handleSizeChange(val) {
            this.parmas.pageSize = val
            this.getList()
        },
        handleCurrentChange(val) {
            this.parmas.page = val
            this.getList()
        },



    }
}

</script>
<style lang="scss" scoped></style>